package hittegods.database;

import java.sql.Connection;
import java.sql.DriverManager;

public class MySQLConn {

    private static Connection conn;
    private static IniReader reader;

    public static Connection getConnection() throws Exception {
        if (conn == null) {
            initConnection();
        }
        return conn;
    }

    private static void initConnection() throws Exception {
        reader = new IniReader();
        Class.forName("com.mysql.jdbc.Driver").newInstance();
        conn = DriverManager.getConnection("jdbc:mysql://" + reader.getHost() + ":" + reader.getPort() + "/" + reader.getDatabaseName() + "", reader.getUser(), reader.getPassword());
    }
}